// api数据
import {
  homeCarousel,
  homeIconNav,
  productIist,
  recommendGoodsList,
  SearchSideNav,
  getVerify
} from '../api/index'
// 桥梁
import {
  HOME_CAROUSEL,
  HOME_ICON_NAV,
  HOME_PRODUCT_LIST,
  RECOMMENDGOODSLIST,
  SEARCH_SIDE_NAV_WH,
  VERIFYINFO
} from './mutations-type'
export default {
  // 获取轮播图
  async resHomeCarousel ({ commit }) {
    const result = await homeCarousel()
    console.log(result)
    if (result.status !== 200) return
    commit(HOME_CAROUSEL, result.results)
  },
  // 获取首页图标导航
  async reshomeIconNav ({ commit }) {
    const result = await homeIconNav()
    if (result.status !== 200) return
    commit(HOME_ICON_NAV, result.results)
  },
  // 获取商品列表
  async resProductIist ({ commit }) {
    const result = await productIist()
    if (result.success_code !== 200) return
    commit(HOME_PRODUCT_LIST, result.message.goods_list)
  },
  // 推荐商品
  async resRecommendGoods ({ commit }, params) {
    const result = await recommendGoodsList(params)
    if (result.status !== 200) return
    commit(RECOMMENDGOODSLIST, result.results)
  },
  async resSearchNav ({ commit }) {
    const result = await SearchSideNav()
    if (result.success_code !== 200) return
    commit(SEARCH_SIDE_NAV_WH, result.message.data)
  },
  // 获取验证码
  async getLoginVerify ({ commit }, params) {
    const result = await getVerify(params)
    if (result.status !== 200) return
    commit(VERIFYINFO, result.data)
  }
}
